import dayjs from 'dayjs'
import {hideCode} from "./index"

export function formDateSex(value) {
    let sex = "男";
    switch (value){
        case 0:
            sex = '未知';
            break;
        case 2:
            sex = '女';
            break;
        default:
            break;
    }
    return sex;
}

export function dateStatus(value) {
    let status = "离线";
    switch (value){
        case 0:
            status = '离线';
            break;
        case 1:
            status = '在线';
            break;
        case 2:
            status = '活跃报警未处理';
            break;
        default:
            break;
    }
    return status;
}

export function dateFormat(val){
    if (val!=null){
        return dayjs(val).format('YYYY-MM-DD HH:mm:ss')
    }else {
        return "暂无数据"
    }
}

export function dateFormatEnd(val){
    if (val!=null){
        return dayjs(val).format('YYYY-MM-DD HH:mm:ss')
    }else {
        return "暂无结束"
    }
}

export function dayFormat(val){
    if (val!=null){
        return dayjs(val).format('YYYY-MM-DD')
    }else {
        return "暂无数据"
    }
}

export function timeFormat(val){
    if (val!=null){
        return dayjs(val).format('HH:mm:ss')
    }else {
        return "暂无数据"
    }
}

export function readTimeFormat(val){
    if (val!=null){
        return dayjs(val).format('YYYY-MM-DD HH:mm:ss')
    }else {
        return "未读"
    }
}

export function hideCodeFilter(val){
    if (val.length<8){
        return hideCode(val,2,1)
    }else {
        return hideCode(val,3,4)
    }
}

export function  equipmentStatus(val){
    let status = "";
    switch (val){
        case 0:
            status = "安装启用";
            break;
        case 1:
            status = "未安装";
            break;
        case 2:
            status = "安装未启用";
            break;
        case 3:
            status = "损坏 ";
            break;
        default:
            break;
    }
    return status;
}

export function  isMaintenanceStatus(val){
    let status = "";
    switch (val){
        case 0:
            status = "正常监控";
            break;
        case 1:
            status = "维保模式";
            break;
        case 2:
            status = "演练模式";
            break;
        default:
            break;
    }
    return status;
}

export function  equipmentType(val){
    let type = "";
    switch (val){
        case 0:
            type = "LNS-W(IOT)";
            break;
        case 1:
            type = "LNJTY-GD-CNB";
            break;
        case 2:
            type = "LNS-Y(IOT)";
            break;
        default:
            break;
    }
    return type;
}


export function  taskType(val){
    let type = "";
    switch (val){
        case 0:
            type = '巡检任务';
            break;
        case 1:
            type = '疏散任务';
            break;
        case 2:
            type = '微型消防站任务 ';
            break;
        case 3:
            type = '消防监控室任务';
            break;
        case 4:
            type = '消防通道疏通任务';
            break;
        case 5:
            type = '消防泵房任务';
            break;
        case 6:
            type = '配电室任务';
            break;
        case 7:
            type = '罐区任务';
            break;
        case 10:
            type = '夜保任务';
            break;
        default:
            break;
    }
    return type;
}

export function companyType (val){
    let type = "";
    switch (val){
        case 0:
            type = "总队";
            break;
        case 1:
            type = "支队";
            break;
        case 2:
            type = "大队";
            break;
        case 3:
            type = "中队 ";
            break;
        case 4:
            type = "微型消防站 ";
            break;
        case 5:
            type = "消控室 ";
            break;
        case 6:
            type = "警务站 ";
            break;
        default:
            break;
    }
    return type;
}
export function noticeType(val){
    let type = "系统通知";
    switch (val){
        case 0:
            type = '系统通知';
            break;
        default:
            break;
    }
    return type;
}
export function  noticeFeedback(val){
    let noticeFeedback = "未反馈";
    switch (val){
        case 0:
            noticeFeedback = '未反馈';
            break;
        case 1:
            noticeFeedback = '已反馈';
            break;
        default:
            break;
    }
    return noticeFeedback;
}
export function readedStatus(val){
    let status = "未反馈";
    switch (val){
        case false:
            status = '未读';
            break;
        case true:
            status = '已读';
            break;
        default:
            break;
    }
    return status;
}
export function  equipmentOnlineStatus(val){
    let status = "";
    switch (val){
        case "00":
            status = '无事件更新';
            break;
        case "01":
            status = '火警';
            break;
        case "02":
            status = '故障';
            break;
        case "03":
            status = '启动';
            break;
        case "04":
            status = '停动';
            break;
        case "05":
            status = '隔离';
            break;
        case "06":
            status = '释放';
            break;
        case "07":
            status = '监管';
            break;
        case "08":
            status = '反馈';
            break;
        case "09":
            status = '动作';
            break;
        case "0A":
            status = '复位操作';
            break;
        case "0B":
            status = '恢复';
            break;
        default:
            break;
    }
    return status;
}

export function  checkRecordType(val){
    let checkRecordType = "";
    switch (val){
        case 0:
            checkRecordType = '消防隐患';
            break;
        case 2:
            checkRecordType = '维保工单';
            break;
        case 3:
            checkRecordType = '维保任务';
            break;
        case 4:
            checkRecordType = '巡检任务';
            break;
        default:
            break;
    }
    return checkRecordType;
}
export function  assessmentType(val){
    let checkRecordType = "";
    switch (val){
        case 0:
            checkRecordType = '消防考核';
            break;
        case 1:
            checkRecordType = '企业内部考核';
            break;
        default:
            break;
    }
    return checkRecordType;
}

export function receiveStatus(val){
    let receiveStatus = "";
    switch (val){
        case 0:
            receiveStatus = '未领取';
            break;
        case 1:
            receiveStatus = '已领取';
            break;
        default:
            break;
    }
    return receiveStatus;
}

export function workOrderStatus(val) {
    let workOrderStatus="";
    switch (val) {
        case 0:
            workOrderStatus = '已生成';
            break;
        case 1:
            workOrderStatus = '分配完成';
            break;
        case 2:
            workOrderStatus ='已确认';
            break;
        case 3:
            workOrderStatus='开始维保';
            break;
        case 4:
            workOrderStatus='维保中';
            break;
        case 5:
            workOrderStatus='维保完成';
            break;
        default:
            break;

    }
    return workOrderStatus;
}
//工单状态
export function stateWorkOrder(val) {
    let stateWorkOrder="";
    switch (val) {
        case 0:
            stateWorkOrder = '已生成';
            break;
        case 1:
            stateWorkOrder = '已分配';
            break;
        case 2:
            stateWorkOrder ='已确认';
            break;
        case 3:
            stateWorkOrder='开始执行';
            break;
        case 4:
            stateWorkOrder='沟通中';
            break;
        case 5:
            stateWorkOrder='执行中';
            break;
        case 6:
            stateWorkOrder='维保管理员审核中';
            break;
        case 7:
            stateWorkOrder='已完成';
            break;
        case 8:
            stateWorkOrder='等待消防审核';
            break;
        case 9:
            stateWorkOrder='继续整改';
            break;
        case 10 :
            stateWorkOrder="业主购买物料中"
            break;
        case 11 :
            stateWorkOrder="维保代购"
            break;
        case 12 :
            stateWorkOrder="维保购买物料中"
            break;
        case 13 :
            stateWorkOrder="购买完成"
            break;
        case 14:
            stateWorkOrder="业主管理员审核中"
            break;
        default:
            break;

    }
    return stateWorkOrder;
}
//隐患状态
export function hiddenDangerStatus(val) {
    let hiddenDangerStatus="";
    switch (val) {
        case 0:
            hiddenDangerStatus = '已生成';
            break;
        case 1:
            hiddenDangerStatus = '已分配';
            break;
        case 2:
            hiddenDangerStatus ='已确认';
            break;
        case 3:
            hiddenDangerStatus='开始执行';
            break;
        case 4:
            hiddenDangerStatus='执行中';
            break;
        case 5:
            hiddenDangerStatus='已完成';
            break;
        case 6:
            hiddenDangerStatus='继续执行';
            break;
        case 7:
            hiddenDangerStatus='已转维保工单';
            break;
        case 8:
            hiddenDangerStatus='等待企业审核';
            break;
        case 9:
            hiddenDangerStatus='已延期，等待消防审核';
            break;
        case 10:
            hiddenDangerStatus='等待消防审核';
            break;
        default:
            break;

    }
    return hiddenDangerStatus;
}


export function maintenanceTaskStatus(val) {
    let maintenanceTaskStatus="";
    switch (val) {
        case 0:
            maintenanceTaskStatus = '已生成待分配';
            break;
        case 1:
            maintenanceTaskStatus = '已分配待执行';
            break;
        case 2:
            maintenanceTaskStatus ='确认收到任务';
            break;
        case 3:
            maintenanceTaskStatus='开始执行';
            break;
        case 4:
            maintenanceTaskStatus='执行中';
            break;
        case 5:
            maintenanceTaskStatus='执行完成';
            break;
        default:
            break;

    }
    return maintenanceTaskStatus;
}

export function enterpriseType(val){
    let dominantType = "";
    switch (val){
        case 0:
            dominantType = '应急管理局';
            break;
        case 1:
            dominantType = '消防总队';
            break;
        case 2:
            dominantType = '消防支队';
            break;
        case 3:
            dominantType = '消防大队';
            break;
        case 4:
            dominantType = '消防中队';
            break;
        case 5:
            dominantType = '警务站/应急指挥中心';
            break;
        case 6:
            dominantType = '安全企业';
            break;
        case 7:
            dominantType = '维保企业';
            break;
        default:
            break;
    }
    return dominantType;

}

export function square(value){
    //判断是否是数字
    if(value === '' || value === null || value === undefined){
        return '--';
    }else{
        if (value > 0 && value < 0.1) {
            return value+"平方米";
        }
        var val = Math.round(parseFloat(value)) / 10000;
        var arr = val.toString().split('.');
        if (arr.length === 1) { //个位数
            return val.toString() + '.00'+"平方米";
        } else {
            if (arr[1].length === 1) { //只有一位小数
                return val.toString() + '0'+"平方米";
            } else {
                return val+"平方米";
            }
        }
    }
}
export function  maintenanceEquipmentStatus(val){
    let maintenanceEquipmentStatus = "";
    switch (val){
        case 0:
            maintenanceEquipmentStatus = "良好";
            break;
        case 1:
            maintenanceEquipmentStatus = "损坏";
            break;
        default:
            break;
    }
    return maintenanceEquipmentStatus;
}
export function  feedbackPerson(val){
    let feedbackPerson = "";
    switch (val){
        case "0":
            feedbackPerson = "超级管理员";
            break;
        default:
            break;
    }
    return feedbackPerson;
}
export function alarmStatus(val){
    let alarmStatus = "";
    switch (val){
        case 0:
            alarmStatus = "火情以上报";
            break;
        case 1:
            alarmStatus = "火情通知开始处置";
            break;
        case 2:
            alarmStatus = "处置完毕";
            break;
        default:
            break;
    }
    return alarmStatus;
}
export function isEquipment(val){
    let isEquipment="";
    switch (val) {
        case false:
            isEquipment="否"
            break;
        case true:
            isEquipment="是"
            break;
        default:
            break;
    }
    return isEquipment;
}


export function agencyStatus(val){
    let agencyStatus = "未处置";
    switch (val){
        case 0:
            agencyStatus = '未处置';
            break;
        case 1:
            agencyStatus = '已收到';
            break;
        default:
            break;
    }
    return agencyStatus;
}

export function fireStatus(val){
    let fireStatus = "";
    switch (val){
        case 0:
            fireStatus = "火情已发生";
            break;
        case 1:
            fireStatus = "演练已开始";
            break;
        case 2:
            fireStatus = "火情已结束";
            break;
        default:
            break;
    }
    return fireStatus;
}

export function signType(val){
    let signType = "";
    switch (val){
        case "0":
            signType = "上班签到";
            break;
        case "1":
            signType = "下班签退";
            break;
        default:
            break;
    }
    return signType;
}
export default {
    install(Vue) {
        Vue.filter('formDateSex', formDateSex)
        Vue.filter('dateFormat', dateFormat)
        Vue.filter('hideCodeFilter', hideCodeFilter)
        Vue.filter('equipmentStatus', equipmentStatus)
        Vue.filter('equipmentType', equipmentType)
        Vue.filter('taskType', taskType)
        Vue.filter('companyType', companyType)
        Vue.filter('noticeType', noticeType)
        Vue.filter('noticeFeedback', noticeFeedback)
        Vue.filter('readedStatus', readedStatus)
        Vue.filter('receiveStatus', receiveStatus)
        Vue.filter('enterpriseType', enterpriseType)
        Vue.filter('readTimeFormat', readTimeFormat)
        Vue.filter('square', square)
        Vue.filter('workOrderStatus',workOrderStatus )
        Vue.filter('maintenanceEquipmentStatus',maintenanceEquipmentStatus )
        Vue.filter('feedbackPerson',feedbackPerson)
        Vue.filter('isMaintenanceStatus',isMaintenanceStatus)
        Vue.filter('timeFormat',timeFormat)
        Vue.filter('stateWorkOrder',stateWorkOrder)
        Vue.filter('hiddenDangerStatus',hiddenDangerStatus)
        Vue.filter('alarmStatus',alarmStatus)
        Vue.filter('isEquipment',isEquipment)
        Vue.filter('checkRecordType',checkRecordType)
        Vue.filter('equipmentOnlineStatus',equipmentOnlineStatus)
        Vue.filter('assessmentType',assessmentType)
        Vue.filter('agencyStatus',agencyStatus)
        Vue.filter('maintenanceTaskStatus',maintenanceTaskStatus)
        Vue.filter('fireStatus',fireStatus)
        Vue.filter('signType',signType)
    }
}
